package com.mobile.challenge.util;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;

/**
 * @Author Touge
 * @Date 2020/11/3 17:52
 * @Description
 */
public class RestartTools {

    public static void restartApp(Context context) {
        PackageManager packageManager = context.getPackageManager();
        if (null == packageManager) {
            return;
        }
        final Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
        if (intent != null) {
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            context.startActivity(intent);
        }
    }
}
